import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:gkb_signalr/gkb_signalr.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  late GKBSignalR _gkbSignalr;
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              TextButton(
                onPressed: () {
                  _gkbSignalr = GKBSignalR(
                    url: 'url',
                    token: 'HttpHeaderHelp.authorization',
                  );
                  _gkbSignalr.connect();
                },
                child: const Text('连接'),
              ),
              TextButton(
                onPressed: () {
                  _gkbSignalr.stop();
                },
                child: const Text('断开连接'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
